
public class Tablero {
	int N = 3;
	int[][] tablero = new int [N][N];
	int circulo = 0;
	int cruz = 1;
	
	public Tablero(){
		for ( int i=0; i < N; i++ ) {
			for ( int j=0; j < N; j++ ){
				this.tablero[i][j] = -1;
			}
	     }

	}
	public void setFicha(int c, int i, int j){
		this.tablero[i][j] = c;
	}
	
	public int cantidadPosGanadoras(int c){
		int cant = 0;
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(posicionGanadora(c, i, j, 1)){
					cant++;
				}
			}
		}
		return cant; 
	}
	public boolean posicionGanadora(int c, int i, int j, int cant){
		if(cant == this.N -1 ){
			return true;
		}
		else if(i+1 < N){
			if(this.tablero[i+1][j]==c){
				return (posicionGanadora(c, i+1, j, cant+1)); 
			}
			else{
				return (posicionGanadora(c, i+1, j, cant));
			}
		}
		else if(j+1 < N){
			if(this.tablero[i][j+1]==c){
				return (posicionGanadora(c, i, j+1, cant+1)); 
			}
			else{
				return (posicionGanadora(c, i, j+1, cant));
			}
		}
		else if(i-1 >= 0){
			if(this.tablero[i-1][j]==c){
				return (posicionGanadora(c, i-1, j, cant+1)); 
			}
			else{
				return (posicionGanadora(c, i-1, j, cant));					
			}
		}
		else if(j-1 >= 0){
			if(this.tablero[i][j-1]==c){
				return (posicionGanadora(c, i, j-1, cant+1)); 
			}
			else{
				return (posicionGanadora(c, i, j-1, cant));
			}
		}
		else if(i+1 < N && j+1 < N){
			if(this.tablero[i+1][j+1]==c){
				return (posicionGanadora(c, i+1, j+1, cant+1)); 
			}
			else{
				return (posicionGanadora(c, i+1, j+1, cant));
			}
		}
		else if(i-1 >= 0 && j-1 >= 0 ){
			if(this.tablero[i-1][j-1]==c){
				return (posicionGanadora(c, i-1, j-1, cant+1)); 
			}
			else{
				return (posicionGanadora(c, i-1, j-1, cant));
			}
		}
		else return false;
	
	}
	public void printTablero(){
		for ( int i=0; i < N; i++ ) {
			for ( int j=0; j < N; j++ ){
				System.out.print(this.tablero[j][i]);
				System.out.print(" | ");
			}
			System.out.println("");
	     }
	}
}
